import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:jd_shop/page/tabs/TabPage.dart';
import 'package:jd_shop/provider/AppProvider.dart';
import 'package:jd_shop/provider/CartProvider.dart';
import 'package:jd_shop/routers/routers.dart';
import 'package:provider/provider.dart';

final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    //填入设计稿中设备的屏幕尺寸,单位dp
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => CartProvider()),
        ChangeNotifierProvider(create: (_) => AppProvider()),
      ],
      child: ScreenUtilInit(
        designSize: const Size(360, 690),
        minTextAdapt: true,
        splitScreenMode: true,
        builder: (context, child) {
          return MaterialApp(
            navigatorKey: navigatorKey,
            title: 'Flutter Demo',
            theme: ThemeData(
                primarySwatch: Colors.blue,
                splashColor: const Color.fromRGBO(0, 0, 0, 0), //去掉点击扩散效果
                appBarTheme: const AppBarTheme(
                  centerTitle: true,
                  backgroundColor: Colors.blue,
                  titleTextStyle: TextStyle(
                    color: Colors.white,
                    fontSize: 18,
                    fontWeight: FontWeight.bold,
                    backgroundColor: Colors.blue,
                  ),
                  iconTheme: IconThemeData(
                    color: Colors.white,
                  ),
                )),
            debugShowCheckedModeBanner: false,
            initialRoute: "/",
            onGenerateRoute: onGenerateRoute,
            home: TabPage(),
          );
        },
      ),
    );
  }
}
